home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SPACE 2
/
SPACE - Library 2 - Volume 1.iso
/
utility
/
602
/
sr
/
sr.doc
< prev
next >
Wrap
Text File
|
1992-04-26
|
3KB
|
69 lines
SR - String Replace.
Version 1.0.
Michael Alan Dorman
I wrote this program because I have *no idea* how to use
SED, and wouldn't really care to learn it for something as
trivial as what this program is designed to do.
The problem was simple: GCC 2.1 thought that the file
curses.ext was a precompiled header file, and was bitching at me
when it tried to #include it while I was trying to rebuild the
curses package. So I wrote this program to look through all the
source files and replaces curses.ext with cursese.h.
I added some error checking, and since I use MiNT a lot,
I also added a switch to kill output on non-error conditions, so
that it would background nicely.
Now I'm distributing it, source and executable. To use
it, just type:
sr [-q] <search string> <replacement string> <file> [file...]
The -q makes it "quiet" so that it only does output if
there's an error--it's an optional argument. The other stuff it
pretty self-explanitory. If either the search or replacement
strings is gonna have a space or such, you need to put them in
quotes (assuming your shell supports that). There needs to be at
least one file, up to ?.
Don't worry, I'm not charging anything. It was an hour's
hack. That includes the time it took me to recompile the curses
package. It was fun.
Oh, two things--it doesn't do regular expressions (use
SED for stuff that requires that), and it doesn't glob its own
files. For those among us who aren't UN*X-heads, that means it
doesn't do wild-cards. Sorry. I don't feel like adding it (I've
written enough globbing code to last me a lifetime). Use a shell
that does wild-card expansion on the command line (BASH 1.10 for
TOS or MiNT, Gulam I believe, Mupfel (the shell from Gemini)), or
at least one that does batch files. I guess that makes me sound
like a jerk, but it's just the truth. Source is included--if you
write the globbing code, I'd love to see it.
Actually, that's not totally true--I'll probably get
bored one day and add globbing support and GEM-ize it and make it
really pretty. But don't expect it anytime soon--I'm about to
graduate from college, and I've hit that final-semester crunch.
Other things--since it was compiled with GCC 2.1 and the
GNU libraries at PatchLevel 79, it *does* do ARGV. That's part
of why I don't support command-line wild-cards. If you can send
a command-line that long, well, why not let the shell do it?
As usual with software of this nature, I take no
responsibility for anything it may do to your computer. It works
for me, but it might trash your HD if your setup isn't exactly
like mine, and I won't give you lots of money if that happens.
Well, if you've gotten this far, and you don't think I'm
some stuck up jerk, and you use the program, drop me a (virtual)
line:
Michael Alan Dorman
M.DORMAN2 on GEnie
mdorman1@ua1vm.ua.edu on the Internet